package com.demo.touca.config;

import com.demo.touca.service.job.*;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.support.ApplicationContextFactory;
import org.springframework.batch.core.configuration.support.GenericApplicationContextFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableAutoConfiguration
@EnableBatchProcessing(modular = true)
public class SpringBatchConfiguration {

    @Bean
    public ApplicationContextFactory firstJobContext() {
        return new GenericApplicationContextFactory(FirstJobConfig.class);
    }

    @Bean
    public ApplicationContextFactory multiJobContext() {
        return new GenericApplicationContextFactory(MultiJobConfig.class);
    }

    @Bean
    public ApplicationContextFactory deciderJobContext() {
        return new GenericApplicationContextFactory(DeciderJobConfig.class);
    }

    @Bean
    public ApplicationContextFactory nestedJobContext() {
        return new GenericApplicationContextFactory(NestedJobConfig.class);
    }

    @Bean
    public ApplicationContextFactory splitJobContext() {
        return new GenericApplicationContextFactory(SplitJobConfig.class);
    }
}